﻿@{
    ViewBag.Title = "EventBindOn";
    Layout = "~/Views/Shared/_BPage.cshtml";
}

<h2>Event Bind On</h2>
<br />
<input id="btnTriggerAll" type="button" value="trigger all" />
<br /><br />
<input id="btnChangeValue" type="button" value="change value" />
<script type="text/javascript">
    var person = Backbone.Model.extend({
        defaults: {
            name: "",
            sex: "女",
            age: 32,
            score: 120
        }
    });
    var man = new person();

    
    man.on("change:age", function () {
        /*
        var simpleDialog = new ZeusSimpleDialog("dialogChangeAge", "Change Age", "您触发了change:age事件", "small");
        simpleDialog.Init();
        simpleDialog.Show();
        */
        ZEUS.DEBUG.log('您触发了change:age事件');
    });
    var event_fun = function () {
        /*
        var simpleDialog = new ZeusSimpleDialog("dialogChangeName", "Change Name", "您触发了change:name事件", "small");
        simpleDialog.Init();
        simpleDialog.Show();
        */
        ZEUS.DEBUG.log("您触发了change:name事件");
    }
    man.on("change:name", event_fun);
    

    man.on("all", function (value) {
        /*
        var simpleDialog = new ZeusSimpleDialog("dialogTriggerAll", "Trigger All", "您触发了all事件中" + value, "small");
        simpleDialog.Init();
        simpleDialog.Show();
        */
        ZEUS.DEBUG.log("您触发了all事件中" + value);
    });

    $('#btnTriggerAll').click(function () {
        man.trigger("all");
    });

    $('#btnChangeValue').click(function () {
        man.set("name", "kelvin");
        man.set("age", 35);
    });
</script>

